package com.mingsoft.led;

import org.springframework.stereotype.Component;

import com.mingsoft.led.camera.CameraBean;

@Component("statusBean")
public class StatusBean {
	private Navigations currentNav = Navigations.VIDEO;
	private boolean controllerOn = false;
	private boolean videoPaused = false;

	public Cmd generateCmd(String command, String param) {
		FileBean fileBean = FileBean.getInstance();
		Cmd cmd = new Cmd();
		cmd.setParam(param);
		cmd.setCmd(Commands.getCommands(command));

		switch (cmd.getCmd()) {
		case PPT_OPEN:
			if (currentNav == Navigations.PPT) {
				cmd.setParam(fileBean.getPptFiles()
						.get(Integer.parseInt(param)).getAbsolutePath());
			}
			break;
		case VIDEO_OPEN:
			if (currentNav == Navigations.VIDEO) {
				cmd.setParam(fileBean.getVideoFiles()
						.get(Integer.parseInt(param)).getAbsolutePath());
			}
			break;
		case PICTURE_OPEN:
			if (currentNav == Navigations.PICTURE) {
				cmd.setParam(fileBean.getPictureFiles()
						.get(Integer.parseInt(param)).getAbsolutePath());
			}
			break;
		case CAMERA_OPEN:
			if (currentNav == Navigations.CAMERA) {
				cmd.setParam(CameraBean.getInstance()
						.getCameraConfigByName(param).toParamString());
			}
			break;
		}
		return cmd;
	}

	public Navigations getCurrentNav() {
		return currentNav;
	}

	public void setCurrentNav(Navigations currentNav) {
		this.currentNav = currentNav;
	}

	public Navigations getPptNav() {
		return Navigations.PPT;
	}

	public Navigations getVideoNav() {
		return Navigations.VIDEO;
	}

	public Navigations getCameraNav() {
		return Navigations.CAMERA;
	}

	public Navigations getPictureNav() {
		return Navigations.PICTURE;
	}

	public boolean isControllerOn() {
		return controllerOn;
	}

	public void setControllerOn(boolean controllerOn) {
		this.controllerOn = controllerOn;
	}

	public boolean isVideoPaused() {
		return videoPaused;
	}

	public void setVideoPaused(boolean videoPaused) {
		this.videoPaused = videoPaused;
	}
}
